<template>
	<view class="box">
		<view class="item">
			<view class="title">昵称</view>
			<view>
				<input type="text" value="" placeholder="请输入昵称" maxlength="10" />
				<!-- <i class="iconfont icon-youjiantou"></i> -->
			</view>
		</view>
		<view class="item">
			<view class="title">生日</view>
			<view>
				<picker mode="time" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
					<view>
						<input type="button" :value="date" placeholder="请输入生日" @focus="bindDateChange" />
						<i class="iconfont icon-youjiantou"></i>
					</view>
				</picker>
			</view>
		</view>
		<view class="item">
			<view class="title">身高</view>
			<view>
				<picker @change="bindshengaoChange" :value="indexshengao" :range="shengao">
					<view>
						<input type="button" :value="shengao[indexshengao]" placeholder="请输入身高" />
						<i class="iconfont icon-youjiantou"></i>
					</view>
				</picker>
			</view>
		</view>
		<view class="item">
			<view class="title">体重</view>
			<view>
				<picker @change="bindtizhongChange" :value="indextizhong" :range="tizhong">
					<view>
						<input type="button" :value="tizhong[indextizhong]" placeholder="请输入体重" />
						<i class="iconfont icon-youjiantou"></i>
					</view>
				</picker>
			</view>
		</view>
		<view class="item">
			<view class="title">属性</view>
			<view>
				<picker @change="bindtizhongChange" :value="indexshuxing" :range="shuxing">
					<view>
						<input type="button" :value="shuxing[indexshuxing]" placeholder="请输入属性" />
						<i class="iconfont icon-youjiantou"></i>
					</view>
				</picker>
			</view>
		</view>
		<view class="item">
			<view class="title">性别</view>
			<view class="sex">
				<view @tap="stycss" :class="[sex? 'nan': 'nv']"><i class="iconfont icon-nan"></i></view>
				<view @tap="stycss" :class="[!sex? 'nan': 'nv']"><i class="iconfont icon-nvxing"></i></view>
			</view>
			<view class="sexx">
				<view>男生</view>
				<view>女生</view>
			</view>
		</view>
		<view class="button">性别注册后将无法更改，请慎重选择</view>
		<button type="primary" class="btn" @tap="jump()">下一步</button>
	</view>
</template>

<script>
export default {
	data() {
		const currentDate = this.getDate({
			format: true
		});
		return {
			// 生日
			date: currentDate,
			// 身高
			shengao: ['150cm', '160cm', '170cm', '180cm','190cm','200cm'],
			indexshengao:0,//单选下标
			// 体重
			tizhong:['40KG', '45KG', '50KG', '55KG','60KG','65KG'],
			indextizhong:0,//单选下标
			index:0,//单选下标
			//sex切换
			sex:true,
			//属性
			shuxing:['40KG', '45KG', '50KG', '55KG','60KG','65KG'],
			indexshuxing:0,
		};
	},
	computed: {
		// 开始时间
		startDate() {
			return this.getDate('start');
		},
		//结束时间
		endDate() {
			return this.getDate('end');
		}
	},
	methods: {
		jump() {
			uni.navigateTo({
				url: '../zhuce/zcxiangxi'
			});
		},
		// 日期
		bindDateChange: function(e) {
			this.date = e.target.value;
		},
		// 身高
		bindshengaoChange: function(e) {
			console.log('picker发送选择改变，携带值为', e.target.value);
			this.indexshengao = e.target.value;
		},
		// 体重
		bindtizhongChange: function(e) {
			console.log('picker发送选择改变，携带值为', e.target.value);
			this.indextizhong = e.target.value;
		},
		// 男女切换样式
		stycss: function(e){
			this.sex=!this.sex
			console.log(this.sex?"男":"女")
		},
		//属性
		bindshuxingChange: function(e) {
			console.log('picker发送选择改变，携带值为', e.target.value);
			this.indextizhong = e.target.value;
		},
		// 获取时间的方法
		getDate(type) {
			const date = new Date();
			let year = date.getFullYear();
			let month = date.getMonth() + 1;
			let day = date.getDate();

			if (type === 'start') {
				year = year - 60;
			} else if (type === 'end') {
				year = year + 2;
			}
			month = month > 9 ? month : '0' + month;
			day = day > 9 ? day : '0' + day;
			return `${year}-${month}-${day}`;
		}
	}
};
</script>

<style lang="less">
page {
	.box {
		width: 100%;
		height: 100%;
		background-color: #1f1e24;
		overflow: hidden;
		position: relative;
		.item {
			padding: 0 45upx;
			margin-top: 30upx;
			& > view:nth-child(1) {
				color: rgba(255, 224, 147, 1);
				font-size: 30upx;
			}
			& > view:nth-child(2) {
				display: flex;
				justify-content: space-between;
				align-items: center;
				font-size: 28upx;
				height: 72upx;
				background-color: rgba(242, 242, 242, 0.1);
				margin-top: 21upx;
				input {
					flex: 1;
					padding: 0 10upx;
					color: #999999;
				}
				i {
					color: #999999;
					margin-left: 15upx;
					margin-right: 15upx;
				}
			}
			& > view:nth-child(2) {
				picker {
					width: 100%;
					view {
						width: 100%;
						display: flex;
						justify-content: space-between;
						align-items: center;
						font-size: 28upx;
						height: 72upx;
						input {
							flex: 1;
							padding: 0 10upx;
							color: #999999;
						}
						i {
							color: #999999;
							margin-left: 15upx;
							margin-right: 15upx;
						}
					}
				}
			}
			.sex {
				background: none !important;
				display: flex;
				justify-content: center !important;
				& > view {
					width: 202upx;
					height: 71upx;
					// background:rgba(31,30,36,1);
					border: 3upx solid rgba(255, 224, 147, 1);
					text-align: center;
					line-height: 71upx;
					.icon-nan {
						font-size: 45upx;
						font-weight: 600;
					}
					.icon-nvxing {
						font-size: 50upx;
						font-weight: 600;
					}
				}
				.nan{
					background-color: #ffe093;
					color: #1f1e24;
				}
				.nv {
					background-color: #1f1e24;
					color: #1f1e24;
				}
			}
			.sexx {
				display: flex;
				justify-content: center !important;
				& > view {
					width: 202upx;
					text-align: center;
					font-size: 26upx;
					color: rgba(252, 250, 241, 1);
					margin-top: 26upx;
				}
			}
		}
		// .text {
		// 	font-size: 26upx;
		// 	color: rgba(153, 153, 153, 1);
		// 	margin-top: 15upx;
		// 	text-align: center;
		// }
	}
	.button{
		font-size: 26upx;
		color: rgba(153, 153, 153, 1);
		margin-top: 15upx;
		text-align: center;
	}
	.btn {
		width: 635upx;
		height: 88upx;
		background: rgba(255, 224, 147, 1);
		border-radius: 0;
		position: absolute;
		bottom: 37upx;
		color: rgba(31, 30, 36, 1);
		font-size: 32upx;
		line-height: 88upx;
		margin-left: 50%;
		transform: translateX(-50%);
	}
}
</style>
